package com.solotiger.geographic.util;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * 常见系统应用工具类
 */
public class SystemUtil {


    private static final String TAG = "SystemUtil";

    /**
     * 安全打开activity
     */
    public static void startActivity(Context ctx, Intent intent) {

        if (ctx == null)
            return;
        if (intent == null) {
            return;
        }
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
            ctx.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Log.e(TAG, "Unable start Activity. intent=" + intent, e);
        } catch (SecurityException e) {
            Log.e(TAG, "Unable start Activity. intent=" + intent, e);
            e.printStackTrace();
        }

    }
}
